package com.wangsd.system.service;

import com.gitee.fastmybatis.core.query.Query;
import com.gitee.fastmybatis.core.query.Sort;
import com.wangsd.system.entity.Brand;
import com.wangsd.system.mapper.BrandMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 业态Service业务层处理
 *
 * @author wsd
 * @date 2021-06-18
 */
@Service
public class BrandService {
    @Autowired
    private BrandMapper brandMapper;

    /**
     * 查询业态
     *
     * @param id 业态ID
     * @return 业态
     */
    public Brand selectBrandById(Long id) {
        return brandMapper.getById(id);
    }

    /**
     * 查询业态列表
     *
     * @param brand 业态
     * @return 业态
     */
    public List<Brand> selectBrandList(Brand brand) {
        Query query = new Query();
        query.orderby("id", Sort.DESC);
        List<Brand> list = brandMapper.list(query);
        return list;
    }

    /**
     * 新增业态
     *
     * @param brand 业态
     * @return 结果
     */
    public int insertBrand(Brand brand) {
        return brandMapper.saveIgnoreNull(brand);
    }

    /**
     * 修改业态
     *
     * @param brand 业态
     * @return 结果
     */
    public int updateBrand(Brand brand) {
        return brandMapper.updateIgnoreNull(brand);
    }

    /**
     * 删除业态信息
     *
     * @param id 业态ID
     * @return 结果
     */
    public int deleteBrandById(Long id) {
        return brandMapper.deleteById(id);
    }
}
